<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2017 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See doc/COPYRIGHT.rdoc for more details.

++#%>
<% @entries.each do |entry| %>
  <% tr_id = Digest::MD5.hexdigest(entry.path)
   depth = params[:depth].to_i %>
  <%  ent_path = replace_invalid_utf8(entry.path)   %>
  <%  ent_name = replace_invalid_utf8(entry.name)   %>
  <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= h(entry.kind) %>">
    <td class="filename" style="padding-left: <%=18 * depth%>px;">
      <% if entry.dir? %>
        <a class="icon-context dir-expander"
              title="<%= I18n.t('js.label_expand') %>"
              href="javascript:"
              data-element="<%= "##{tr_id}" %>"
              data-url="<%= url_for(action: 'show',
                                    project_id: @project,
                                    path: to_path_param(ent_path),
                                    rev: @rev,
                                    depth: (depth + 1),
                                    parent_id: tr_id) %>">
          &nbsp
        </a>
      <% end %>
      <%=  link_to h(ent_name),
          {action: (entry.dir? ? 'show' : 'changes'), project_id: @project, path: to_path_param(ent_path), rev: @rev},
          class: 'icon-context ' + (entry.dir? ? 'icon-folder' : "icon-ticket #{Redmine::MimeType.css_class_of(ent_name)}"), aria: {label: (entry.dir? ? t('label_folder') : t('activerecord.attributes.attachment.file')) + " #{h(ent_name)}"} %>
    </td>
    <td class="hidden-for-sighted"> <%= depth %></td>
    <td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.dir? %></td>
    <% changeset = @project.repository.find_changeset_by_name(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
    <td class="revision"><%= link_to_revision(changeset, @project) if changeset %></td>
    <td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
    <td class="author"><%= changeset.nil? ? h(replace_invalid_utf8(entry.lastrev.author.to_s.split('<').first)) : h(changeset.author) if entry.lastrev %></td>
    <td class="comments"><%=h truncate(Changeset.to_utf8(changeset.comments, changeset.repository.repo_log_encoding), length: 50) unless changeset.nil? %></td>
  </tr>
<% end %>
